package com.errorfinding.common.music;


import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @CrossOrigin 解决跨域问题
 */
@CrossOrigin
@RestController
@RequestMapping("/music")
public class MusicControoler {


    @GetMapping("/musicData")
    public JSONObject musicData(@RequestParam(value = "keywords",defaultValue = "五月天") String keywords){
        String url =  "http://music.eleuu.com/search?keywords="+keywords;
        String result2 = HttpRequest.get(url)
                .execute().body();
        JSONObject jsonObject = JSONObject.parseObject(result2);

        return jsonObject;
    }




}
